<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@ page import="edu.itla.medifacil.persistence.enums.Attribute" %>
<%@ page import="edu.itla.medifacil.persistence.entities.TestResult" %>
<%@ page import="edu.itla.medifacil.helpers.Utilities" %>
<%@page import="java.util.*;" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css" type="text/css" />
	<link rel="stylesheet" href="../css/style.css" />
	
<!-- Google Libraries API: JQuery, JQuery UI -->
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>

	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
	<script type="text/javascript" src="../js/forms/utilities.js"></script>
	
	<script type="text/javascript" src="../js/tests/index.js"></script>

	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<title>Resultados de Pruebas</title>
	
	<% 
		System.out.println("entre");
		if( request.getSession().getAttribute("tests") == null ) 
			response.sendRedirect("/MediFacil/Tests.do"); 
	%>
</head>
<body>
	<jsp:include page="../navigation/header.jsp" >
		<jsp:param value="tests" name="active"/>
	</jsp:include>

	<div id="container">
		<div title="Nueva Prueba" style="display:none;" id="addTestDialog" class="dialog">
			<form id="addTestForm" action="/MediFacil/Tests.do" method="POST">
				<input name="action" value="addTest" type="hidden" />
				
				<div class="input text required">
					<label for="description">Descripci&oacute;n</label>
					<input type="text" id="description" name="description" />
				</div>
				
				<button type="submit">Salvar</button>
			</form>
		</div>
	
		<a class="action" href="/MediFacil/Tests.do?action=add" >Agregar Resultado de Prueba</a>
		
		<a class="action" id="addTest" href="#" >Agregar Prueba</a>
		
		<div class="clear"></div>
	<% 
		for( TestResult test : (List<TestResult>)request.getSession().getAttribute("tests") ) { 
			Map<Integer, String> patientAttributes = Utilities.extractPersonAttributes(test.getPatient());
	%>
	
		<div class="patient">
			<div class="picture floatL">
			<% 
				String picture = "../img/unknown.png"; 
				if( patientAttributes.get( Attribute.FOTO.getId() ).length() > 0 )
					picture = ".." + patientAttributes.get( Attribute.FOTO.getId() );
			%>
			
			<img width="60" height="60" src="<%= picture %>" />
			</div>
			
			<div class="info floatR">
				<p>
					<a href="/MediFacil/Tests.do?action=view&id=<%= test.getId() %>"><%= test.getTest().getDescription() %></a>
				</p>
				<p><%= test.getPatient().getName() + " " + test.getPatient().getLastName() %></p>
			</div>
		</div>
	<% }//End foreach %>
		<div class="clear"></div>
	</div>
	
	<jsp:include page="../navigation/copyright.html" />
</body>
</html>